<?php
class DI_Inject
{
	private static $_stores = array();
	
	public $value;
	
	public static function register($key, $value)
	{
		self::$_stores[$key] = $value;
	}
	
	public function instance()
	{
		$value = $this->value;
		
		if(isset(self::$_stores[$value]))
		{
			$value = self::$_stores[$value];
		}
		
		if(is_string($value) && class_exists($value))
		{
			if(@is_callable("{$value}::getInstance"))
			{
				$value = $value::getInstance();
			}
			else
			{
				$value = new $value();
			}
		}
		
		return $value;
	}
}